import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };
  handleAdd = () => {
    // this.setState({ count: this.state.count + 1 });
    this.setState((preState) => {
      return {
        count: preState.count + 1,
      };
    });
  };
  render() {
    return (
      <div>
        <h3>{this.state.count}</h3>
        <button onClick={this.handleAdd}>点我</button>
      </div>
    );
  }
}
